package model.posterminal;

import java.io.Serializable;
import java.util.ArrayList;

import model.BaseObject;
import model.configuration.ConfigData;
import model.database.ObjectDataProvider;
import org.simpleframework.xml.*;

@Root(name = "posterminal")
public class Posterminal extends BaseObject implements Serializable{
	
	
	@Element(name = "serialnumber", required=false)
	String serialNumber; // posterminal serial
	
	@Element(name = "inventorynumber", required=false)
	String inventoryNumber; // posterminal inventory number
	
	@Element(name = "posterminalmodel", required=false)
	PosterminalModel posterminalModel;
	
	public Posterminal(){
		super();
	}
	
	protected void setStoredProcedureName() {
		this.insertStoreProcedureName = "insertPosterminal";
		this.updateStoreProcedureName = "updatePosterminal";
		this.deleteStoreProcedureName = "deletePosterminal";
		this.selectStoreProcedureName = "selectPosterminal";
	}
	
	/**
	 * Create posterminal object with some data
	 * @param serialNumber posterminal serial number
	 * @param inventoryNumber posterminal inventory number
	 */
	public Posterminal(String serialNumber, String inventoryNumber) {
		super();
		this.serialNumber = serialNumber;
		this.inventoryNumber = inventoryNumber;
	}
	
	public String getSerialNumber() {
		return serialNumber;
	}
	
	public void setSerialNumber(String serialNumber) {
		this.serialNumber = serialNumber;
	}
	
	public String getInventoryNumber() {
		return inventoryNumber;
	}
	
	public void setInventoryNumber(String inventoryNumber) {
		this.inventoryNumber = inventoryNumber;
	}
	
	public PosterminalModel getPosterminalModel() {
		return posterminalModel;
	}

	public void setPosterminalModel(PosterminalModel posterminalModel) {
		this.posterminalModel = posterminalModel;
	}
	
	
//	public long getId() {
//		return id;
//	}
	
	/**
	 * Save object data in database
	 * @throws Exception
	 */
//	public void save() throws Exception {
//		String storedProcedure = "posterminalSave";
//		
//		// new object in database?
//		if (this.id == ConfigData.NOVALUELONG) {
//			// save object in database and get it id
//			this.id = ((Posterminal) this.sendObject2GetObject(this, this.getClass(), storedProcedure)).getId();
//		}
//		else {
//			// just save object
//			this.sendObject2GetObject(this, this.getClass(), storedProcedure);
//		}
//	}

	/**
	 * Return all posterminal stored in database;
	 * @return
	 * @throws Exception
	 */
	public ArrayList<Posterminal> getAllPosterminalList() throws Exception {
		ArrayList<Posterminal> result = new ArrayList<Posterminal>();
		
		result = (ArrayList<Posterminal>) this.selecttObjectList(null);
		
		return result;
	}

}
